package customer.zspt.cn.customer.Widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import customer.zspt.cn.customer.R;

/**
 * Created by Administrator on 2018/6/6 0006.
 */

public class TabView extends RelativeLayout {


    private final TextView tab_rb;
    private final TextView msg_count;
    private final ImageView tab_icon;
    public TabView(Context context) {
        this(context, null);
    }
    public TabView(Context context, AttributeSet attrs) {
        super(context, attrs);
        View.inflate(context, R.layout.activity_main_tab, this);
        tab_rb = (TextView) findViewById(R.id.tab_rb);
        tab_icon = (ImageView) findViewById(R.id.tab_icon);
        msg_count = (TextView) findViewById(R.id.msg_count);
    }
    /**
     * 设置tab图标和文字
     */
     public void setTabText(String TabText)
     {
         tab_rb.setText(TabText);
     }
    /**
     * 设置图标
     * @param RescoureIcon
     */
    public void setTabIcon(int RescoureIcon)
    {
        tab_icon.setBackgroundResource(RescoureIcon);
    }
    /**
     * 设置未读消息数
     */
    public void setMsg_count(String count)
    {
        int Msg_count = Integer.parseInt(count);
        if(Msg_count<=0)
        {
            msg_count.setVisibility(GONE);
        }
        else
        {
            msg_count.setVisibility(VISIBLE);
            msg_count.setText(Msg_count<=99?Msg_count+"":"99+");
        }
    }

    /**
     * 设置图标状态
     */
    public void selectState(boolean state)
    {
        tab_icon.setSelected(state);
    }


}


